home *** CD-ROM | disk | FTP | other *** search
- // Copyright ©1997 Zdzisiek Losvik, Gdynia 81-523, Przemyslawa 12a, POLAND
- // All rights reserved.
-
- // ********************************************************************************
- // ** Header to the FuncComp.Lib Library ** 02.1997 **
- // ********************************************************************************
- // ** This small lib contains two very useful functions that: **
- // ** **
- // ** (i) Convert string of characters into a fast computable internal form **
- // ** (ii) Fast computes the value of converted string given the value of X **
- // ** **
- // ********************************************************************************
-
- // ** THIS IS NOT FREE, I have spend few days on creating it and I think it's worth $5
- // ** Please send me the money if you are going to write something using this lib
-
- // • All data is kept in global variables (1.2kB)
- // • All operations are performed using 'double' data type
- // • Errors are returned via global variable funcErr
- // • ANSI math is used to perform opertions (math.h)
- // • I wish, it was also PowerPC native but I haven't got the right compilator
- // so I'm waiting to get some money and to buy one
-
- // • Operators: +, -, *, /, ^
- // • Backets - over 20
- // • Functions: SIN, COS, TAN, COT, trigonometric functions
- // SINH, COSH, TANH, COTH, hyperbolic trigonometric functions
- // ARCSIN, ARCCOS, ARCTAN, ARCCOT, arc trig. func.
- // ARCSINH,ARCCOSH,ARCTANH,ARCCOTH,arc hyp. trig. func.
- // EXP, LOG, LN, INT,
- // FRAC, SQRT, ABS, !, fraction, square root, absolute value, factorial
- // °, X, E, PI degree, X, base of the exponential, pi
-
- // • Example : 1° (sin): x-x^3/3!+x^5/5!-x^7/7!+x^9/9!
- // 2° (parabola): 2x^2-3x+5
- // 3° (any other): 2(5x-2)(3x+5)-2ln(x^2-3x)+xx
-
-
- // Don't know how to use it ??? Look at the example.
-
- /*
-
- void main(void)
- {
- Str255 s = "2x^2-3x+5"; // any math C-style string
- double y;
-
- BuildFunction(s); // build it (internally)
-
- y = CalcFunc(10);
- }
-
- */
-
- // ********************************************************************************
- // *** The glue ***
- // ********************************************************************************
-
- // ERROR codes returned while BUILDING function
-
- enum { badSyntaxErr = 1, //
- missingLBErr, // unpaired right bracket
- missingRBErr, // unpaired left bracket
- unknownErr, // unknown operation/function
- // global var. 'funcInPos' contains the begining of unknown string
- anExtraPointErr, // too many points in a number
- tooComplexErr // this should never occur
- };
-
- // ERROR code returned while performing mathematic operations
-
- #define noValueErr 1
-
-
- // *******************************************************************************
- // Global variables
-
- extern short funcInPos; // Where was the problem (if there was)
- extern short funcErr; // Contains an error of last operation
-
-
- // *******************************************************************************
- // Functions
-
- // Convert the function
- extern void BuildFunction (char * inS); // inS C-style string
-
- // Compute it's value given X
- extern double CalcFunc(double X);
-
- // Send me any comments
-
-